package com.wkbb.basic.service;

import com.github.pagehelper.PageInfo;
import com.wkbb.basic.model.Agent;
import com.wkbb.basic.model.Organization;
import com.wkbb.common.base.BaseService;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.common.dto.basic.AccountOrgDto;
import com.wkbb.common.dto.basic.OrganizationDto;

import java.util.List;
import java.util.Map;

/**
 * @author Alger Yang
 */
public interface OrganizationService extends BaseService<Organization> {

    /**
     * 获取单个组织详情
     *
     * @param id 组织ID
     * @return 组织详情
     * @throws Exception 抛出异常
     */
    OrganizationDto getInfo(Long id) throws Exception;

    /**
     * 获取组织信息列表
     *
     * @param params 参数
     * @return 组织信息列表
     */
    List<OrganizationDto> getList(Map<String, Object> params);

    /**
     * 获取组织信息分页列表
     *
     * @param params   参数
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @return 组织信息分页列表
     */
    PageInfo<OrganizationDto> getPage(Map<String, Object> params, Integer pageNo, Integer pageSize);

    /**
     * 更新组织信息
     *
     * @param entity 组织信息
     * @param isBack 是否后台
     * @throws Exception 抛出异常
     */
    ResultDTO update(Organization entity, boolean isBack) throws Exception;

    List<AccountOrgDto> getAccountOrgList(Long accountId);

    Organization getOrgByAccount(Long accountId);

    List<OrganizationDto> getNewOrgListByOldIds(List<Long> oldOrgIds);

    PageInfo<OrganizationDto> getOrgListByPage(Map<String, Object> params, Integer pageNo, Integer pageSize);

    /**
     * 根据用户ID查询代理商和学校信息
     *
     * @param userId 用户ID
     *
     * @throws Exception 抛出异常
     */
    OrganizationDto getAgentInfoByUserId(Long userId)throws Exception;

    /**
     * 根据用户ID查询学校信息
     *
     * @param userId 用户ID
     *
     * @throws Exception 抛出异常
     */
    OrganizationDto getOrgInfoByUserId(Long userId)throws Exception;

    Organization getOrgByOldOrgId(Long oldOrgId);

    Organization getOrgByName(Integer orgType, String orgName);

    List<Organization> getEducationList(Integer orgType,OrganizationDto organizationDto);

    void recursiveOrganization(List<Organization> orgList,Integer orgType,List<Organization> organizationList);

    List<Map<String, Object>> getOrgCountByType(OrganizationDto organizationDto);
    /**
     * 根据当前登录人所属的教育局查询整个子教育局下面的全部学校
     * @param organizationDto
     * @return
     * @throws Exception
     */
    List<Organization> getOrganizationList(OrganizationDto organizationDto);

    void deleteById(Long orgId);

    ResultDTO insertOrganization(Organization orgInfo)throws Exception ;

    List<Map<String, Object>> getOrgCountStatByOrgan(Map<String, Object> params);

    List<Map<String, Object>> getOrgListByOrgan(Map<String, Object> params);

    List<Map<String, Object>> getOrgDataStat(Map<String, Object> params);

    /**
     * 查询所有申请中的APPID申请结果并绑定用户组
     */
    void searchAPPID(String webankAppid,String webankSecret,Long orgId, String webankOrgId);

    List<OrganizationDto> getOrgListByCity(Long orgId);

    Map<String, Integer> getOrgDataCount(Map<String, Object> params);

    Map<String, Object>  getOrganizationCount();

    ResultDTO<Long> insertAgent(Agent data) throws Exception;

    PageInfo<Agent> getAgentListByPage(Map<String, Object> params, int pageNo, int pageSize);

    Agent getAgentById(Integer id);
}
